package com.doit.demo01;

import java.io.*;
import java.util.ArrayList;

public class test02 {
    public static void main(String[] args) throws IOException {
        Reader r1 = new FileReader("D:\\work\\abc\\IO练习题\\第二题\\1.txt");
        Reader r2 = new FileReader("D:\\work\\abc\\IO练习题\\第二题\\2.txt");
        Writer w = new FileWriter("D:\\work\\abc\\IO练习题\\第二题\\3.txt");

        ArrayList<char[]> arr = new ArrayList<>();
        int len ;
        char[] chars = new char[1024];
        while ((len=r1.read(chars))!=-1){
            arr.add(chars);
            System.out.println(new String(chars,0,len));
        }
        w.write(arr.get(0));
        w.flush();
        while ((len=r2.read(chars))!=-1){
            arr.add(chars);
            System.out.println(new String(chars,0,len));
        }
        w.write(arr.get(1));
        w.flush();

        w.close();r1.close();r2.close();
    }
}
